const Net = require('../../common.js')
Page({
  data: {
    active: 1,
    order_num: ''
  },
  onLoad: function (options) {
    Net.data({
      order_num: options.order_num
    })
  },
  onTapView(e) {
    Net.data({
      active: e.currentTarget.id
    })
  },
  onLogisitics(e) {
    Net.data({
      logistics_num: e.detail.value
    })
  },
  onDeliverIs() {
    if (!Net.data('logistics_num')) {
      Net.toast('请填写快递单号', 'none')
      return false
    }
    Net.link('v1/changeOrder', {
      order_num: Net.data('order_num'),
      logistics_num: Net.data('logistics_num')
    }, function (res) {
      if (res.data.code == 200) {
        Net.toast('发货成功', 'success')
        setTimeout(() => {
          Net.PageRoter('_address', '', 'red')
        }, 1500);
      } else {
        Net.toast(res.data.msg, 'none')
      }
    })
  },
  onReady: function () {},
  onShow: function () {},
  onHide: function () {},
  onUnload: function () {},
  onPullDownRefresh: function () {},
  onReachBottom: function () {},
  onShareAppMessage: function () {}
})